package com.yic.module.base.dal.mysql.erpcentermapping;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.base.dal.dataobject.erpcentermapping.ErpCenterMappingDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.base.controller.admin.erpcentermapping.vo.*;

/**
 * ERP工作中心映射 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ErpCenterMappingMapper extends BaseMapperX<ErpCenterMappingDO> {

    default PageResult<ErpCenterMappingDO> selectPage(ErpCenterMappingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ErpCenterMappingDO>()
                .eqIfPresent(ErpCenterMappingDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ErpCenterMappingDO::getErpCenterId, reqVO.getErpCenterId())
                .eqIfPresent(ErpCenterMappingDO::getErpCenterCode, reqVO.getErpCenterCode())
                .likeIfPresent(ErpCenterMappingDO::getErpCenterName, reqVO.getErpCenterName())
                .eqIfPresent(ErpCenterMappingDO::getWorkshopId, reqVO.getWorkshopId())
                .orderByDesc(ErpCenterMappingDO::getId));
    }

    default List<ErpCenterMappingDO> selectList(ErpCenterMappingExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ErpCenterMappingDO>()
                .eqIfPresent(ErpCenterMappingDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ErpCenterMappingDO::getErpCenterId, reqVO.getErpCenterId())
                .eqIfPresent(ErpCenterMappingDO::getErpCenterCode, reqVO.getErpCenterCode())
                .likeIfPresent(ErpCenterMappingDO::getErpCenterName, reqVO.getErpCenterName())
                .eqIfPresent(ErpCenterMappingDO::getWorkshopId, reqVO.getWorkshopId())
                .orderByDesc(ErpCenterMappingDO::getId));
    }

    default ErpCenterMappingDO selectByErpCenterId(String erpCenterId) {
        return selectOne(new LambdaQueryWrapperX<ErpCenterMappingDO>()
                .eq(ErpCenterMappingDO::getErpCenterId, erpCenterId));
    }
}
